package cn.jsj.finance.bank;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.jsj.pojo.TblCashAccount;
import cn.jsj.utils.SysLogger;
/**
 * 查询现金账信息处理类
 * @author LI
 *
 */
 public class SearchCashInfo extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
	 public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// 调试信息
		 	cn.jsj.utils.SysLogger.PrintInfo("查询现金账信息！！");

		 	//获得参数
		 	String cashYear=request.getParameter("cashYear");
		 	String cashMonth=request.getParameter("cashMonth");
		 	//判断是否输入了月份
		 	if(cashMonth.length()==0){
		 		cashMonth="";
		 	}

		 	//调试信息
		 	cn.jsj.utils.SysLogger.PrintInfo("can------>"+cashYear+"   "+cashMonth);

		 	//获得参数：1.第几条开始。2.一页显示几条
			int startNumb=Integer.parseInt(request.getParameter("start"));
			int totalNumb=Integer.parseInt(request.getParameter("limit"));

			//调试信息
			cn.jsj.utils.SysLogger.PrintInfo("start---->"+startNumb+"   total--------->"+totalNumb);

			//新建前台与DB交互对象
			cn.jsj.bgtodb.SearchCashProperty scp=new cn.jsj.bgtodb.SearchCashProperty();
			scp.setCashMonth(cashMonth);
			scp.setCashYear(cashYear);
			scp.setStartNumb(startNumb);
			scp.setTotalNumb(totalNumb);

			//获得银行帐信息条数
			cn.jsj.dao.TblCashAccountDAO tcad=new cn.jsj.dao.TblCashAccountDAO();
			int cashNumber=tcad.getSearchCashNumb(scp);

			//调试信息
			cn.jsj.utils.SysLogger.PrintInfo("tiaoshu----->"+cashNumber);

			//银行帐信息列表
			java.util.List<TblCashAccount> cashList=new java.util.LinkedList<TblCashAccount>();
			cashList=tcad.getSearchCashInfo(scp);

			//转换成JSON型数据
			cn.jsj.utils.ProduceJsonData pjd=new cn.jsj.utils.ProduceJsonData();
			String jsonData=pjd.jsonFromList(cashList, cashNumber);
			//调试信息
			SysLogger.PrintInfo(jsonData);
			//输出到客户端
			java.io.PrintWriter pw=response.getWriter();
			pw.println(jsonData);
			pw.flush();
			pw.close();
	}
}